package com.xzc.refactory.method.replaceTempWithQuery;

public class C6 {
    int _quantity;
    int _itemPrice;

    double getPrice() {
        //类似的，提炼discountFactor
        //提炼完成后，感觉世界清晰了，多么简单，这个函数体直接反映了函数名
        return basePrice() * discountFactor();
    }

    private int basePrice() {
        return _quantity * _itemPrice;
    }

    private double discountFactor() {
        if (basePrice() > 1000)
            return 0.95;
        else
            return 0.98;
    }
}
